package com.example.taskdemo.controller;

import com.example.taskdemo.service.AsyncService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lzh
 * @date 2019/10/10 - 15:14
 */
@RestController
public class AsynController {

    private static final Logger logger = LoggerFactory.getLogger(AsynController.class);


    @Autowired
    private AsyncService asyncService;

    @RequestMapping("/testAsync")
    public String testAsync() {
        logger.info("TestAsync 开始执行!");
        long startTime = System.currentTimeMillis();
        //后台执行异步任务
        asyncService.testNoRespNoParamAsync();
        logger.info("TestAsync 执行结束,耗时: {}!", (System.currentTimeMillis() - startTime) / 1000);

        return "End!";
    }
}
